home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dec92.zip / CSTREAM.H < prev    next >
C/C++ Source or Header  |  1992-07-25  |  742b  |  35 lines

  1. Listing 1
  2.  
  3. // CSTREAM.H
  4.  
  5. #ifndef _CSTREAM_H
  6. #define _CSTREAM_H
  7.  
  8. #include <iostream.h>
  9. #include <conio.h>
  10.  
  11. class ConioBuffer: public streambuf {
  12. public:
  13.                ConioBuffer ()     { unbuffered(1); }
  14.     virtual   ~ConioBuffer ()     {}
  15.     virtual int overflow (int ch) {
  16.                 if(ch=='\n')
  17.                     { clreol(); putch('\r'); }
  18.                 putch(ch);
  19.                 if(ch=='\n')
  20.                     clreol();
  21.                 return ch;
  22.                }
  23. };
  24.  
  25. class ConioStream : public ostream {
  26.     ConioBuffer *buf;
  27. public:
  28.   ConioStream() : ostream() { buf=new ConioBuffer(); ios::init(buf); }
  29.   virtual ~ConleStream ()     { if(buf) delete buf; }
  30. } ;
  31.  
  32. #endif  //_CSTREAM_H
  33.  
  34.  
  35.